package model

import (
	"github.com/go-xorm/xorm"
	_ "github.com/go-sql-driver/mysql"
	"log"
)

var x *xorm.Engine

func init(){
	var xErr error
	x, xErr = xorm.NewEngine("mysql", "root:new_password@tcp(127.0.0.1:3306)/cashier?charset=utf8")
	if xErr != nil {
		log.Fatal("数据库连接失败:", xErr)
	}
	if err := x.Sync2(new(Consumption), new(ConsumptionBeautician), new(ConsumptionEmployees), new(ConsumptionItems), new(ConsumptionPaymentMethods), new(ConsumptionProducts),
		new(GiftItems), new(ConsumptionMode), new(IntegralRule), new(PaymentMethods), new(MemberInformation), new(MemberPurchasePackage), new(Store), new(CustomerType),
		new(CustomerTypeConsumptionMode), new(CustomerTypePaymentMethod), new(CashierRule), new(ModifiableItem), new(PaymentMethods), new(ConsumptionModePoint), new(Clerk),
		new(Products), new(TreatmentProducts), new(TreatmentItems), new(ConsumptionTreatment), new(CancellationRecodes), new(ComposeItem), new(ConsumptionMemberPurchasePackage),
		new(RefundRecords)); err != nil {
		log.Fatal("数据表同步失败:", err)
	}
}